feat: add yarn workspace command with smart filter routing#226
feat: add yarn workspace command with smart filter routing#226denneulin wants to merge 7 commits intortk-ai:masterfrom
Conversation
…plate filtering - Add yarn_cmd.rs with run() for workspace command execution - Implement filter_yarn_output() stripping YN-prefixed, resolution/fetch/link, classic boilerplate - Add 7 unit tests covering clean output, YN prefix, resolution steps, empty, classic, mixed, and token savings - Add mod yarn_cmd declaration in main.rs for compilation - Follow npm_cmd pattern: capture output, filter stdout, pass stderr, track tokens, tee on failure, preserve exit codes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… parsing tests - Add mod yarn_cmd declaration (alphabetical after wget_cmd) - Add Commands::Yarn variant with trailing_var_arg and allow_hyphen_values - Add match arm routing to yarn_cmd::run() with verbose and skip_env - Add 5 Clap parsing tests: basic, scoped package with slash, without run, extra args, simple package Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ross-module access - Make filter_tsc_output pub(crate) in tsc_cmd.rs - Make filter_generic_lint pub(crate) in lint_cmd.rs - Make extract_test_summary pub(crate) in runner.rs - Add FilterRoute enum, PREFIX_EXCLUSIONS, route_script(), apply_filter() to yarn_cmd.rs - apply_filter includes panic catch_unwind and empty-output guard for graceful degradation
…with tracking labels and tests - Replace passthrough-only filtering with capture+strip+route+filter pattern - Add "ok checkmark" guard to skip routing when all output is boilerplate - Routing-aware tracking labels: "vitest (via yarn workspace)" for routed, "yarn workspace (passthrough)" for unrouted - Add 11 comprehensive tests: 4 routing, 5 apply_filter integration, 1 guard, 1 end-to-end - Fix clippy suggestion: use PREFIX_EXCLUSIONS.contains() instead of iter().any()
- Check exit code after command execution, before filter routing - Failed yarn commands now print raw stdout/stderr without filter processing - Tee raw output and track with "(failed)" label on failure path - Move exit_code extraction before routing to share variable with safety net - Prevents misleading "TypeScript compilation completed" on yarn errors Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- test_failed_command_should_not_route_to_filter: proves tsc filter masks yarn errors without early-exit - test_successful_command_still_routes_through_filters: verifies happy path (strip/route/filter) is unchanged - 20 yarn_cmd tests total (18 existing + 2 new), full suite 437 pass Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review: PR #226Thanks for this PR! The Bugs found1. Non-workspace commands broken — 2. Boilerplate leaks — 3. Vitest routing broken — 4. Double stderr — Line 290 prints filtered output, line 293 prints raw stderr again on top. 5. Subcommand interception — Minor
Architecture is solid, just needs these fixes. Happy to re-review! |
Summary
Add
rtk yarn workspace <pkg> [run] <script>command that strips yarn boilerplate and routes script outputthrough existing specialized filters for maximum token savings.
headers (
yarn run v1.x,Done in Xs,infolines). Returnsok ✓when output is pure boilerplate.vitest→ vitest parser,tsc/typecheck→ tsc filter,lint/lint:*→ generic lint filter,prettier/format→ prettier filter,test/test:*→ test runner summarytest:e2e,test:playwright,test:cypress,lint:fix→passthrough)
catch_unwindon filter panics, empty-output guard, fallback to stripped outputwith stderr warning
without routing through filters (prevents error masking)
Changes
src/yarn_cmd.rsfilter_yarn_output(),route_script(),apply_filter(),run()+ 25 testssrc/main.rsCommands::Yarnwithtrailing_var_arg+ 5 Clap parsing testssrc/lint_cmd.rsfilter_generic_lint: fn →pub(crate)src/runner.rsextract_test_summary: fn →pub(crate)src/tsc_cmd.rsfilter_tsc_output: fn →pub(crate)Test plan
cargo fmt --all --checkpassescargo clippy --all-targetspassescargo test --allpasses (30+ new tests)rtk yarn workspace <pkg> run viteston a real yarn workspace projectrtk yarn workspace <pkg> run typecheckwith typecheck not existing